import type { AxiosRequestConfig } from "axios";

export type CustomSuccessData<T> = {
    code:number
    msg:string
    data:T
    [keys:string]:unknown
}
  
export type Request = {
    <T>(
      url: string,
      params?: Record<string, unknown>|FormData,
      config?: AxiosRequestConfig
    ): Promise<CustomSuccessData<T>>;
}

export type AddEquipmentParam = {
      equipmentName:string
      equipmentDes:string
}

export type DeleteEquipmentParam = {
      equipmentUUID:string
}



export type ListParam = {
  name:string
  index:number
  pageSize:number
}

export type ListResponse<T> = {
  records:Array<T>,
  total:number
}

export type Equipment = {
  id:string,
  equipmentName:string,
  equipmentUuid:string,
  equipmentDes:string,
  connected:boolean,
  createTime:string,
  updateTime:string
}

export type LoginParam = {
  username:string,
  password:string,
}

export type LoginResult = {
  username:string,
  token:string
}

export type UserInfo = {
  username:string
}

// {
//   "success":1,
//   "heartbeat":90,
//   "respiratory":0,
//   "heartbeatArray":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
//   "respiratoryArray":[27,34,33,21,0,232,212,204,208,224,244,4,11,7,251,0,0,0,0,0]
// }


export type HrrInfo = {
  success:number,
  heartbeat:number,
  respiratory:number,
  heartbeatArray:number[],
  respiratoryArray:number[]
}

export type EquipmentDetailInfo = {
  equipmentName:String,
  equipmentUUID:String,
  ip:String|null,
  connectedAt:String|null
  keepALive:String|null
  connected:Boolean
}

export type QueryEquipmentHistory = {
  startDate:Date,
  endDate:Date,
  equipmentUUID:String|undefined
}

export type QueryEquipmentHistory1 = {
  Date1:Date,
  equipmentUUID:String|undefined
}

export type HRR = {
  heatbeat:number,
  breath:number,
  createTime:String
}


export type EquipmentHistory = {
  equipmentUUID:String,
  equipmentName:String,
  hrrList:Array<HRR>
  heatbeatList:Array<number>
  breathList:Array<number>
}

export type DataParam = {
  startDate:Date,
  endDate:Date,
}

export type Dashboard = {
  messageLineChart:LineChartResponseTemplate<number>,
  logLineChart:LineChartResponseTemplate<number>,
  hrrClassifyCount:PieChartData[],
  equipmentCount:number,
  messageCount:number,
  connections:number
}

export type LineChartResponseTemplate<T> = {
  countList:T[],
  timeList:string[],
}

export type HrrClassifyCount = {
  heatBeatNormalCount:number,
  heatBeatDisNormalCount:number,
  breathNormalCount:number,
  breathDisNormalCount:number
}

export type PieChartData = {
  name:string,
  value:number
}